package com.yuanheng100.ems4j.mapper;

import com.yuanheng100.ems4j.model.Ems4jMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface Ems4jMenuMapper {

    @Delete({
        "delete from ems4j_menu",
        "where menuid = #{menuid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer menuid);


    @Insert({
        "insert into ems4j_menu (menuid, appid, ",
        "parentid, menuname, ",
        "url, ordernum, ",
        "permission, description, ",
        "menutype)",
        "values (#{menuid,jdbcType=INTEGER}, #{appid,jdbcType=INTEGER}, ",
        "#{parentid,jdbcType=INTEGER}, #{menuname,jdbcType=VARCHAR}, ",
        "#{url,jdbcType=VARCHAR}, #{ordernum,jdbcType=SMALLINT}, ",
        "#{permission,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, ",
        "#{menutype,jdbcType=SMALLINT})"
    })
    int insert(Ems4jMenu record);


    @Select({
        "select",
        "menuid, appid, parentid, menuname, url, ordernum, permission, description, menutype",
        "from ems4j_menu",
        "where menuid = #{menuid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="menuid", property="menuid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="appid", property="appid", jdbcType=JdbcType.INTEGER),
        @Result(column="parentid", property="parentid", jdbcType=JdbcType.INTEGER),
        @Result(column="menuname", property="menuname", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="ordernum", property="ordernum", jdbcType=JdbcType.SMALLINT),
        @Result(column="permission", property="permission", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="menutype", property="menutype", jdbcType=JdbcType.SMALLINT)
    })
    Ems4jMenu selectByPrimaryKey(Integer menuid);



    @Update({
        "update ems4j_menu",
        "set appid = #{appid,jdbcType=INTEGER},",
          "parentid = #{parentid,jdbcType=INTEGER},",
          "menuname = #{menuname,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "ordernum = #{ordernum,jdbcType=SMALLINT},",
          "permission = #{permission,jdbcType=VARCHAR},",
          "description = #{description,jdbcType=VARCHAR},",
          "menutype = #{menutype,jdbcType=SMALLINT}",
        "where menuid = #{menuid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Ems4jMenu record);
}